package com.thf.controller.news;

import com.alibaba.fastjson.JSON;
import com.thf.model.ResultData;
import com.thf.service.NewsService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.ServletException;
import java.io.IOException;
import java.util.Map;

@Controller
public class NewUpdateController{

    @Resource
    private NewsService newsService ;

    @RequestMapping("/news/edit")
    @ResponseBody
    protected String newUpdate(String val) throws ServletException, IOException {

        Map map = JSON.parseObject(val,Map.class);
        //        -返回值
        ResultData result = newsService.update(map);
//        System.out.println(map);
//       反馈给前端--返回值
        String resJson = JSON.toJSONString(result);
//        resp.getWriter().println(resJson);
        return resJson ;
    }
}
